<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>修改表单属性</title>
</head>

<body>
    <!-- <input type="text" value="请输入内容">
    <button>点击</button> -->
    <div class="box">
        <input type="text">
        <button>点击</button>
    </div>
</body>
<script>
    // var input = document.querySelector('input')
    // var btn = document.querySelector('button')
    // btn.addEventListener('click',function(){
    //     input.value = '你点过来'
    //     this.disabled = true
    // })

    var input = document.querySelector('input')
    var btn = document.querySelector('button')
    var flag = 1
    btn.onclick = function(){
        if(flag==1){
            input.type = 'password'
            flag=0

        }else{
            input.type = 'text'
            flag =1
        }
        console.log(flag);
    }
</script>

</html>